package com.weipu.common.okhttp;

import com.weipu.common.constants.Constant;
import com.weipu.common.constants.ServerConstant;
import com.weipu.common.util.StringUtil;

/**
 * 网络请求Url工具类
 * @author hf
 *
 */
public class UrlUtils {
   public static String getBannerPageUrl(int start,int take,String customerId){
	   return Constant.GETPAGEBANNERS_URL+ "?start=" + start + "&take=" + take+"&cicid="+customerId;
   }
   
   public static String getBannerDetailUrl(String bannerId, String cicid){
	   return Constant.BASE_URL + "Banners/detail"+"?bannerid="+bannerId+"&cicid="+cicid;
   }
   
   /**
    * 获取用户
    * @param bannerId
    * @param cicid
    * @return
    */
   public static String getAccountForUserUrl(String customerId){
	   return Constant.BASE_URL + "users/"+ customerId + "/User";
   }
   
   
   /**
    * 删除用户Wish产品
    * @param username
    * @param sku
    * @return
    */
   public static String getDeleteWishUrl(String username, int sku){
	   return Constant.DELWISHLISTFORUSER_URL + "?username=" + username + "&sku=" + sku;
   }
   
   /**
    * 获取产品列表URL 包含首页 New Arrivals Mvp Top Sellers Latest Discount
    * 以及Category
    * @param startIndex
    * @param pageCount
    * @param orderByField
    * @param startPrice
    * @param endPrice
    * @param beginStar
    * @param categoryId
    * @return
    */
   public static String getProductsUrl(int startIndex, int pageCount, String orderByField,
	        double startPrice, double endPrice, double beginStar, int categoryId){
	   return Constant.GETPRODUCTLISTBYCATEGORYID_URL+ "?keyName="
               + "&StartIndex="
               + startIndex
               + "&pageCount="
               + pageCount
               + "&orderbyField="+orderByField+"&whereStr="+"p>=" + startPrice + "," + "p<=" + endPrice + "," + "s>=" + beginStar+"&CategoryId=" + categoryId;
   }
   
   /**
    * 获取首页功能按钮请求地址
    * @param pageindex
    * @param pagesize
    * @param type
    * @param orderByField
    * @return
    */
   public static String getHomeBtnUrl(int pageindex, int pagesize,String type,String orderByField){
	   String requestUrl="";
		if (Constant.TYPE_TOPSELLERS.equals(type)) {
			requestUrl=Constant.TOPSELLERS_URL;
		} else if (Constant.TYPE_NEWARRIVALS.equals(type)) {
			requestUrl=Constant.NEWARRIVALS_URL;
		} else if (Constant.TYPE_MVP24HRS.equals(type)) {
			requestUrl=Constant.MVPRODUCTS_URL;
		}
//        else if (Constant.TYPE_LATESTDISCOUNT.equals(type)) {
//            requestUrl=Constant.LATESTDISCOUNTS_URL;
//        }
        //US仓版本修改 去除Lastest Discount
        else if (Constant.TYPE_USWAREHOUSE.equals(type)) {
            requestUrl = Constant.USWAREHOUSE_URL;
        }
        else if (Constant.TYPE_SPORTLIGHTS.equals(type)) {
			requestUrl=Constant.SPOTLIGHTS_URL;
		}
	   return requestUrl+"?categoryId=0" + "&pageSize=" + pagesize + "&pageIndex=" + pageindex+"&orderbyField="+orderByField;
  }
   
   /**
    * 查找用户所有订单
    * @param customerId
    * @param orderDisplayType
    * @param orderdatefrom
    * @param pageIndex
    * @param pageSize
    * @return
    */
   public static String getFindOrdersUrl(String customerId,String orderDisplayType, String orderdatefrom, int pageIndex, int pageSize){
	   return Constant.FINDORDERS_URL+"?CustomerID=" + customerId +"&orderDisplayType="+orderDisplayType+ "&orderdatefrom=" + orderdatefrom + "&pageIndex=" + pageIndex
               + "&pageSize=" + pageSize;
   }
   
   /**
    * 产品详情
    * @param sku
    * @return
    */
   public static String getProudctDetialUrl(int sku){
	   return Constant.GETPRODUCTDETAIL_URL+"?SKU="+ sku;
   }
   
   /**
    * 产品评论
    * @param sku
    * @param CICID
    * @param username
    * @param pageindex
    * @param pagesize
    * @return
    */
   public static String getProductReviews(int sku, String CICID, String username, int pageindex,
	        int pagesize){
	   return Constant.CUSOTMERREVIEWLIST_URL+"?SKU=" + sku + "&CICID=" + CICID + "&userName=" + username + "&pageIndex=" + pageindex
               + "&pageSize=" + pagesize;
   }
   
   /**
    * 评论列表
    * @param sku
    * @param CICID
    * @param username
    * @param pageindex
    * @param pagesize
    * @return
    */
   public static String getCommentsListUrl(int sku, String CICID, String username, int pageindex,
	        int pagesize){
	   return Constant.CUSOTMERREVIEWLIST_URL+"?SKU=" + sku + "&CICID=" + CICID + "&userName=" + username + "&pageIndex=" + pageindex
               + "&pageSize=" + pagesize;
   }
   
   /**
    * 搜索
    * @param keyName
    * @param currentEndIndex
    * @param pageCount
    * @param orderByField
    * @param startPrice
    * @param endPrice
    * @param beginStar
    * @return
    */
   public static String getSearchProUrl(String keyName, int currentEndIndex, int pageCount, String orderByField,
	        double startPrice, double endPrice, double beginStar){
	   String whereStr = "p>=" + startPrice + "," + "p<=" + endPrice + ","
				+ "s>=" + beginStar;
	   return Constant.GETSEARCHPRODUCTLIST_URL+"?keyName="+StringUtil.strFilterOut(keyName)+"&CurrentEndIndex=" + currentEndIndex + "&pageCount=" + pageCount
               + "&orderbyField="+orderByField+"&whereStr="+whereStr;
	   /*mapUrl.get(ServerConstant.RequestMethodNameConstant.METHOD_GETSEARCHPRODUCTLIST)
       + "?keyName={keyName}&CurrentEndIndex=" + currentEndIndex + "&pageCount=" + pageCount
       + "&orderbyField={orderByField}&whereStr={whereStr}"*/
   }
   
   /**
    * Banner产品列表
    * @param bannerID
    * @param StartIndex
    * @param pageCount
    * @param orderByField
    * @param startPrice
    * @param endPrice
    * @param beginStar
    * @return
    */
   public static String getBannerProUrl(String bannerID, int StartIndex, int pageCount,
	        String orderByField, double startPrice, double endPrice, double beginStar,long customerID,boolean isFilter,String categoryIds){
	   return Constant.GETBANNERPRODUCTS_URL+"?bannerID=" + bannerID + "&StartIndex=" + StartIndex + "&pageCount=" + pageCount
               + "&orderbyField="+orderByField+"&whereStr="+"p>=" + startPrice + "," + "p<=" + endPrice + "," + "s>=" + beginStar
               +"&customerID="+customerID+"&IsFilter="+isFilter+"&categoryIds="+categoryIds;
   }
   
   /***********Cart 相关接口********************/
   public static String getGetCartURL(long customerId){
	   return Constant.GETCART_URL+ "?customerID="+ customerId ;
   }
   
   public static String getAddCartURL(int sku, int qty, long customerId){
	   return Constant.ADDCART_URL+"?sku="+sku+"&qty="+qty+"&customerID="+ customerId ;
   }
   
   public static String getClearCartURL(long customerId){
	   return Constant.CLEARCART_URL+ "?customerID="+ customerId ;
   }
   
   public static String getRemoveCartURL(int sku, long customerId){
	   return Constant.REMOVESKUFROMCART_URL+ "?sku="+sku+"&customerID="+ customerId ;
   }
   
   public static String getGetCartCountURL(long customerId){
	   return Constant.GETCARTCOUNT_URL+ "?customerID="+ customerId ;
   }
   
   public static String getUpdateCartURL(int sku, int quantity, long customerId){
	   return Constant.UPDATECART_URL+ "?sku="+sku
				+"&qty="+quantity
				+"&customerID="+ customerId;
   }
   
}
